// user controller

const UserModel = require('../model/UserModel')
const __common = require('./common')


async function login(username, password) {
  // 从数据库查询用户
  return await __common(UserModel.findOne({ username, password }))
}

async function register(userInfo = {}) {
  // 插入数据库,并返回
  return await __common(UserModel.create(userInfo))
}

module.exports = { register, login }
